- /* scfctanh.cpp by K.Tsuru */
- // function ID = 9111
- /*********************************************************
- SComplex class
- It returns tanh(z) = {exp(2*z)-1}/{exp(2*z)+1}.
- Let z = x+i*y,
- tanh(x+i*y) = {sinh(2*x)+i*sin(2*y)}/{cosh(2*x)+cos(2*y)}.
- **********************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- #define Usectanh 0
- #define Useez2ctanh 0
-
- SComplex Ctanh(const SComplex& z)
- {
- if(z.IsZero()) return 0.0;
- #if Usectanh // 31.8 sec
- SComplex z2 = 2*z;
- SDouble den = Cosh(z2.Real())+Cos(z2.Imag());
- SDouble rr =Sinh(z2.Real()), ri = Sin(z2.Imag());
-
- den = 1.0/den;
- rr *= den; ri *= den;
- return SComplex(rr, ri);
-
- #elif Useez2ctanh // 16.15 sec
- SComplex e2z = Cexp(2.0*z), r = (e2z - 1.0)/(e2z + 1.0);
-
- return r;
-
- #else // 15.9 sec
- SDouble ch2x, sh2x, c2y, s2y, x2(2*Re(z)), y2(2*Im(z));
-
- Hyperbolic(x2, ch2x, sh2x); // ch2x = cosh(2x) sh2x = sinh(2x)
- CosSinBS(y2, c2y, s2y); // c2y = cos(2y), s2y = sin(2y);
-
- SDouble dr = 1.0/(ch2x + c2y), rr = sh2x * dr, ri = s2y * dr;
-
- return SComplex(rr, ri);
- #endif
- }
scfctanh.cpp : last modifiled at 2015/08/17 16:11:34(1,113 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:09 (Fri Oct 06 15:27:09 2017).